package com.mayikt.main.api.impl.producer;


import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author 余胜军
 * @ClassName UniqueLoginConsumer
 * @qq 644064779
 * @addres www.mayikt.com
 * 微信:yushengjun644
 */
@Component
@RabbitListener(queues = "fanout_sparetire_uniquelogin_queue")
@Slf4j
public class UniqueSparetireLoginConsumer {


    /**
     * @param msg
     * @param message
     * @param channel
     * @throws IOException
     */
    @RabbitHandler
    public void process(String msg, Message message, Channel channel) throws IOException {
        log.info(">>备胎消费者：使用MQ异步的形式记录日志:{}<<", msg);
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        // 手动ack成功
        channel.basicAck(deliveryTag, true);// 手动ack成功 发送通知给 mq服务器端说 消费成功了 msg 从mq服务器端删除
    }
}
